// component/backtorule/backtorule.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    isnavigator:{
      type:Boolean,
      value:false
    },
    iscsorderno:{
      type:Number,
      value:''
    },
    isunsubscribenum:{
      type:String,
      value:''
    } 
  },

  /**
   * 组件的初始数据
   */
  data: {
    tag:'y',
    myval:null,
    detail:null
  },



  /**
   * 组件的方法列表
   */
  methods: {
     /*关闭*/
     onisTrue(e){
      let that = this;
      that.setData({
        isnavigator:false
      })
    },

    checkboxChange(e){
      console.log('checkbox发生change事件，携带value值为：', e.detail.value)
      let that = this;
      let myval=that.data.myval;
      if(typeof(e.detail.value[0])=='undefined'){
        that.setData({
          myval:null
        })
      }else{
        that.setData({
          myval:'y'
        })
      }
      console.log(myval);
    },

    getmsg(e){
      let that = this
      let detail = e.detail.value
        console.log(e)
        console.log(that.properties.iscsorderno)
        that.setData({
          detail:detail 
        })
    },
    oknoinfo(e){
      let  that = this
      let  myval = that.data.myval
      let  detail = that.data.detail
      let  orderinfo=that.properties.iscsorderno   //传入订单号
      let token = wx.getStorageSync('token')
      console.log(myval)
      if(myval==null){
        wx.showToast({
          title: '请点击同意条款',
          icon: 'error',
          duration: 2000
        })
      }else{
       if(detail==null){
        wx.showToast({
          title: '请填写取消原因',
          icon: 'error',
          duration: 2000
        })
       }else{
        wx.request({
          url: 'https://www.yulonging.com/dwweb/wxapi.ashx',
          data: {
           //请求后台的分页数据
           cmd:'CancelOrder',
           token:token,
           OrderNo:orderinfo,
           Cause:detail
          },
          method: "get",
          success(res) {
              if(res.data.STATUS=='Success'){
                wx.showToast({
                  title: '取消成功',
                  icon: 'success',
                  duration: 2000
                })
                that.setData({
                  isnavigator:false
                })
              }else{
                wx.showToast({
                  title: '取消失败',
                  icon: 'error',
                  duration: 2000
                })
              }
          }
        })
       }
      }
    }
  }
})
